package com.example.jvm.jvm01.lesson08;

/**
 * @Description
 * @Date 2021/7/8
 * @Created by Jonathan
 */
public class ClassLoaderDemo extends ClassLoader {

    // 类加载的名字
    private String name;
    private String path;

    public void setPath(String path) {
        this.path = path;
    }

    public ClassLoaderDemo(ClassLoader parent, String name) {
        super(parent);
        this.name = name;
    }

    /**
     * 重写这个方法
     *
     * @param name
     * @return
     * @throws ClassNotFoundException
     */
    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        byte[] data = getDatas(name);
        assert data != null;
        return this.defineClass(name, data, 0, data.length);
    }

    private byte[] getDatas(String name) {
        return null;
    }
}
